package thread;

public class VolitileTest1 {
    private boolean isDone = false;
    public  void test(int a)throws Exception{
        while(!this.isDone){
            Thread.sleep(1000);
        }

    }
    public  void test2(int a)throws Exception{
       this.isDone = true;

    }
    public static void main(String[] args) throws InterruptedException {
        VolitileTest1 wait = new VolitileTest1();
        Thread t = new Thread(() -> {
            try {
                wait.test(11);
            } catch (Exception e) {
                e.printStackTrace();
            }
        });
        Thread t3 = new Thread(() -> {
            try {
                Thread.currentThread().sleep(3000);
                wait.test2(11);
            } catch (Exception e) {
                e.printStackTrace();
            }
        });
        t.start();
        t3.start();
    }
}
